using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

using TimeWar.Objects;

namespace TimeWar
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class GameMap : CurrGameComponent
    {
        public int playerSide;
        protected ArrayList gameDimensions;
        protected int currDimension;


        public GameMap(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
            gameDimensions = new ArrayList();

            Universe myDimension = new Universe(game, playerSide);

            gameDimensions.Add(myDimension);

            


        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.gameComponentInitialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.gameComponentUpdate(gameTime);
        }

        public override void Draw(GraphicsDeviceManager graphics, GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.Black);

            if (gameDimensions != null && gameDimensions.Count > 0)
            {

                //play in current game dimension
                ActiveGameObject currDimension = (ActiveGameObject) gameDimensions[0];
                currDimension.Draw(graphics, gameTime, null);
            }

            

        }

        public override void LoadContent(GraphicsDevice graphicsDevice)
        {
            if (gameDimensions != null && gameDimensions.Count > 0)
            {

                foreach (ActiveGameObject obj in gameDimensions)
                {
                    obj.LoadContent(graphicsDevice);
                    
                }
            }


        }
    }
}